import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Index from '@/views/index/index.vue';
import Music from '@/views/music/index.vue';
import Flyme from '@/views/flyme/index.vue';

// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Index',
    component: Index
  },
  {
    path: '/flyme',
    name: 'Flyme',
    component: Flyme
  },
  {
    path: '/music',
    name: 'Music',
    component: Music
  },
];




// 创建路由
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  // 刷新时滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: "/" });
  location.reload();
}

export default router
